<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>2.倒计时器</title>
</head>

<body>
  <div class="box"></div>
</body>
<script>
  
  function getTime(time) {
    var d1 = new Date(time)
    var d2 = new Date()
    var timeRs = d1 - d2
    var day = parseInt(timeRs / 1000 / 60 / 60 / 24)
    var hour = parseInt(timeRs / 1000 / 60 / 60 % 24)
    var minute = parseInt(timeRs / 1000 / 60 % 60)
    var second = parseInt(timeRs / 1000 % 60)
    return day + '天' + hour + '时' + minute + '分' + second + "秒"
  }
  var flash = setInterval(function () {
    console.log(getTime('2024 / 4 / 17'))
  }, 1000)

</script>

</html>